﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImplicitlyTypedLocalVars
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Implicit Typing *****");
            Console.WriteLine();

            Console.ReadLine();
        }

        /// <summary>
        /// 隐式类型本地变量的数据类型
        /// </summary>
        private static void DeclareImplicitVars()
        {
            var myInt = 0;
            var myBool = true;
            var myString = "Time,marches on...";

            Console.WriteLine("myInt is a: {0}", myInt.GetType().Name);
            Console.WriteLine("myBoll is a: {0}", myBool.GetType().Name);
            Console.WriteLine("myString is a: {0}", myString.GetType().Name);
        }

        /// <summary>
        /// 隐式类型本地变量的用途
        /// </summary>
        private static void QueryOverInts()
        {
            int[] numers = { 10, 20, 30, 40, 1, 2, 3, 8 };
            var subset = from i in numers
                         where i < 10
                         select i;
            Console.Write("Values in subset: ");
            foreach (var i in subset)
            {
                Console.Write("{0} ", i);
            }
            Console.WriteLine();

            Console.WriteLine("subset is a: {0}", subset.GetType().Name);
            Console.WriteLine("subset is defind in: {0}", subset.GetType().Namespace);
        }

    }
}
